<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/utilities/xajax/xajax_core/xajax.inc.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/gui/presenter/PresenterCreateNews.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php';

	
	$xajax = new xajax(); 
	 
	$xajax -> register(XAJAX_FUNCTION, 'setUsername');
	$xajax -> register(XAJAX_FUNCTION, 'selectNews');
	$xajax -> register(XAJAX_FUNCTION, 'showNews');
	
	
	 
	$xajax -> processRequest(); 
	 
	$xajax -> configure('javascript URI','../../../utilities/xajax/');
	
	
	/**
	 * Method to select news
	 */
	function selectNews() {
		$presenterNews = new PresenterCreateNews();
		
		$news = $presenterNews -> selectNews();
		
		$response = new xajaxResponse();
		
		$response -> assign("content", "innerHTML", $news);
		
		return $response;
	}
	
	/**
	 * Method to show single news
	 */
	function showNews($title, $date, $image, $description) {
		$presenterNews = new PresenterCreateNews();
		
		$news = $presenterNews -> showNews($title, $date, $image, $description);
		
		$response = new xajaxResponse();
		
		$response -> assign("content", "innerHTML", $news);
		
		return $response;
	}
	
	
	
	function setUsername($username) {
		$response = new xajaxResponse();
		
		$response -> assign("connectedUser", "innerHTML", "Bienvenido " . $username. " a el Departamento de :  "."Gerencia");
		
		return $response;	
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bienvenido al Sistema Automatizado para la Gesti&oacute;n Empresarial de Recursos - SAGER</title>
<?php 
	$xajax -> printJavascript("../../../utilities/xajax/"); 
?>
<link rel="stylesheet" type="text/css" href="../css/styles.css" />
<link rel="stylesheet" type="text/css" href="../css/styles2.css" />
<script src="../jq/jquery-1.4.1.min.js" type="text/javascript"></script>
<!-- include the Tools -->
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script>
<!-- tooltip styling -->
<link rel="stylesheet" type="text/css" href="http://static.flowplayer.org/tools/css/tooltip-generic.css"/>
<script type="text/javascript">
	function gup( name ){
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp ( regexS );
		var tmpURL = window.location.href;
		var results = regex.exec( tmpURL );
		if( results == null )
			return"";
		else
			return results[1];
	}

	function getTime(){
    	currentTime = new Date()
    	hour = currentTime.getHours()
		minute = currentTime.getMinutes()
		second = currentTime.getSeconds()

		str_second = new String (second)
		if (str_second.length == 1)
		   second = "0" + second
	
		str_minute = new String (minute)
		if (str_minute.length == 1)
		   minute = "0" + minute
	
		str_hour = new String (hour)
		if (str_hour.length == 1)
		   hour = "0" + hour
	
		printableHour = hour + " : " + minute + " : " + second
	
		document.form_watch.watch.value = printableHour
	
		setTimeout("getTime()",1000)
	}
	
	
	function createPayExhele() {
		$("#content").load("../Pay/exhele.php");	
	}
	function createPayInstallation() {
		$("#content").load("../Pay/installation.php");	
	}
	function createPayPublicity() {
		$("#content").load("../Pay/publicity.php");	
	}
	function listClientBills() {
		$("#content").load("../bill/listBillDuctobarra.php");	
	}

	
	function listDuctobarraBills() {
		$("#content").load("../bill/listBill.php"); 
	}
	

	function listProductionOrders() {
		document.form_watch.order.value = 2;
		$("#content").load("../order/order.php"); 
	}
	
	
	function listInstallationOrders() {
		document.form_watch.order.value = 3;
		$("#content").load("../order/order.php"); 
	}
	
	
	function listRequisitions() {
		document.form_watch.order.value = 4;
		$("#content").load("../order/order.php"); 
	}
	
	
	function listOfficeNotes() {
		document.form_watch.order.value = 5;
		$("#content").load("../order/order.php"); 
	}
	
	function listRequestedResources() {
		$("#content").load("../resource/listResources.php"); 	
	}
	
	function clickCreateBranch() {
		$("#content").load("../branch/createBranch.php"); 
  	}
	
	function clickCreateDepartment() {
		$("#content").load("../department/createDepartment.php"); 
  	}
	
	function clickCreateEmployee() {
		$("#content").load("../employee/createEmployee.php"); 
  	}
	
	function clickCreateUser() {
		$("#content").load("../user/createUser.php"); 
  	}
	
	function clickCreateNews() {
		$("#content").load("../news/createNews.php"); 
  	}
	
	function listEmployees() {
		$("#content").load("../employee/listEmployees.php");	
	}
	
	function listUsers() {
		$("#content").load("../user/listUsers.php");
	}
	
	function listBranches() {
		$("#content").load("../branch/listBranches.php");	
	}
	
	function listDepartments() {
		$("#content").load("../department/listDepartments.php");	
	}
	
	function createBookkeeping() {
		$("#content").load("../account/account.php");	
	}
	
	function registerUser() {
		$("#content").load("../user/register.php"); 
  	}

  $(document).ready(function (){
	  $("#content").load("../news/news.php");
	  //loading menu
	  $("#lateralMenu").load("menu.htm");
	  
	  xajax_setUsername(gup('username'));
	  
	  // initialize tooltip
	  $("#myform :input").tooltip({
		  // tweak the position
		  offset: [-10, -4],
		  // use the "slide" effect
		  effect: 'slide'
		  // add dynamic plugin with optional configuration for bottom edge
	  }).dynamic({ bottom: { direction: 'up', bounce: true } });

	  var triggers = $(".modalInput").overlay({
		  // some mask tweaks suitable for modal dialogs
		  mask: {
			  color: '#ebecff',
			  loadSpeed: 200,
			  opacity: 0.9
		  },
	  	  closeOnClick: false
	  });

	  $("#prompt form").submit(function(e) {

		  // close the overlay
		  triggers.eq(1).overlay().close();

		  // get user input
		  var input = $("input", this).val();

		  // do something with the answer
		  triggers.eq(1).html(input);

		  // do not submit the form
		  return e.preventDefault();
	  });
  });
</script>
</head>



<body onload="getTime()">
	<div id="container">
    <!---------------------------------- Top bar ----------------------------------------->
    	<div id="topBar">
        	<form name="form_watch">
            	<div id="connectedUser"></div>
                <input type="text" name="watch" size="12" 
                	onfocus="window.document.form_watch.watch.blur()" />
                <input type="hidden" name="order" />
            </form>
        </div>
        
    <!----------------------------------- Header ----------------------------------------->
    	<div id="header">
        	<img src="../images/logo.jpg" width="100%" height="150px" alt="Ductobarra / Busduct" border="0">
        </div>
    
    <!---------------------------------- Lateral manu ----------------------------------------->
        <div id="lateralMenu"></div>
                

        

    <!--------------------------------- Content --------------------------------------->
           <div id="content">
        <script>
				xajax_selectNews();
			</script>
            </div>
            
    <!--------------------------------- Cuerpo lateral --------------------------------------->
        <div id="cuerpolateral">        
    <!--------------------------------- Register --------------------------------------->
        	
                        
  <!-------------------------------------- Cerrar Sesion ------------------------------------------->
            <h2 class="cuerpolateral">Salir</h2>
            <form id="myform">
			<div id="inputs">            	
            	<table align="center">
                   
                   	<td align="right">
                    	<a href="../home/home.php" >Cerrar Sesion</a>
                   	</td>
                  	
                    
                </table>
            </div>
            </form>        	
    	</div>        
    </div>

  <!-------------------------------------- Footer ------------------------------------------->
    <div id="footer">
    	<p><strong>DUCTOBARRA - Distribuci&oacute;n El&eacute;ctrica Inteligente. RIF J-0373724324</strong></p>
	</div>
</body>
</html>